home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / comms_w / mslot12.zip / SAMPLE.ZIP / CHAT.FRM next >
Text File  |  1995-02-02  |  3KB  |  123 lines

  1. VERSION 2.00
  2. Begin Form Chat 
  3.    Caption         =   "MSlot VBX Sample - Network Chat"
  4.    ClientHeight    =   6375
  5.    ClientLeft      =   1245
  6.    ClientTop       =   1845
  7.    ClientWidth     =   7815
  8.    Height          =   6780
  9.    Left            =   1185
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6375
  12.    ScaleWidth      =   7815
  13.    Top             =   1500
  14.    Width           =   7935
  15.    Begin TextBox txtLocal 
  16.       Height          =   975
  17.       Left            =   120
  18.       TabIndex        =   0
  19.       Text            =   "User Types Text Here"
  20.       Top             =   5280
  21.       Width           =   7575
  22.    End
  23.    Begin TextBox txtChat 
  24.       Height          =   4575
  25.       Left            =   120
  26.       MultiLine       =   -1  'True
  27.       ScrollBars      =   2  'Vertical
  28.       TabIndex        =   1
  29.       TabStop         =   0   'False
  30.       Text            =   "Output Appears Here"
  31.       Top             =   600
  32.       Width           =   7575
  33.    End
  34.    Begin VBMailslots Mailslot1 
  35.       Height          =   420
  36.       Interval        =   250
  37.       Left            =   7320
  38.       MailslotName    =   ""
  39.       MailslotSize    =   4000
  40.       Message         =   ""
  41.       MessageSize     =   400
  42.       Priority        =   0
  43.       Timeout         =   0
  44.       Top             =   120
  45.       Width           =   420
  46.    End
  47. End
  48. Option Explicit
  49.  
  50. Sub Form_Load ()
  51.     ' clear edit boxes
  52.     txtLocal = ""
  53.     txtChat = ""
  54.  
  55.     ' create the mailslot
  56.     Mailslot1.MailslotName = "\MAILSLOT\NetChat"
  57.     Mailslot1.Action = MSLOT_OPEN
  58.  
  59.     ' tell everyone that we're here
  60.     SendMessage "Has joined the group ..."
  61. End Sub
  62.  
  63. Sub Form_Resize ()
  64.     ' resize/position output edit box
  65.     txtChat.Left = 120
  66.     txtChat.Top = 120
  67.     txtChat.Height = Chat.ScaleHeight - 360 - 975
  68.     txtChat.Width = Chat.ScaleWidth - 240
  69.  
  70.     ' resize/position input edit box
  71.     txtLocal.Top = Chat.ScaleHeight - 120 - 975
  72.     txtLocal.Left = 120
  73.     txtLocal.Height = 975
  74.     txtLocal.Width = Chat.ScaleWidth - 240
  75. End Sub
  76.  
  77. Sub Form_Unload (Cancel As Integer)
  78.     SendMessage "Is leaving ..."
  79. End Sub
  80.  
  81. Sub Mailslot1_MessageWaiting (MessageCount As Integer)
  82.     ' read twice to deal with W4Wg bug
  83.     On Error Resume Next
  84.     Mailslot1.Action = MSLOT_READ
  85.     Mailslot1.Action = MSLOT_READ
  86.     On Error GoTo 0
  87.  
  88.     ' add new message to edit box
  89.     If txtChat <> "" Then
  90.         txtChat = txtChat & Chr(13) & Chr(10)
  91.     End If
  92.  
  93.     txtChat = txtChat & Mailslot1.Message
  94.     txtChat.SelStart = Len(txtChat)
  95. End Sub
  96.  
  97. Sub SendMessage (Text)
  98.     Dim TempMessage As String
  99.  
  100.     ' send message
  101.     Mailslot1.Message = Mailslot1.UserName & " (" & Mailslot1.ComputerName & "): " & Text
  102.     Mailslot1.MailslotName = "\\*\MAILSLOT\NetChat"
  103.     Mailslot1.Action = MSLOT_WRITE
  104. End Sub
  105.  
  106. Sub txtLocal_KeyPress (KeyAscii As Integer)
  107.     ' if the user pressed Enter, send result to net
  108.     If KeyAscii = 13 Then
  109.         KeyAscii = 0
  110.  
  111.         SendMessage txtLocal
  112.  
  113.         ' clear edit box
  114.         txtLocal = ""
  115.     End If
  116. End Sub
  117.  
  118. Sub txtLocal_LostFocus ()
  119.     ' make sure focus remains here
  120.     txtLocal.SetFocus
  121. End Sub
  122.  
  123.